<template>
  <el-color-picker v-model="current_field" :show-alpha="showAlphaValue" :disabled="disabledValue" @change="$emit('update:value', current_field)" />
</template>
<script>
export default {
  props: {
    value: {
      type: String,
      default: ''
    },
    args: {
      type: Object,
      required: true,
      default: _ => {
        return {};
      }
    }
  },
  data() {
    return {
      current_field: this.value,
      current_args: this.args
    };
  },
  computed: {
    disabledValue() {
      if (this.current_args.disabled == '1') {
        return true;
      }

      return null;
    },
    showAlphaValue() {
      if (this.current_args.alpha == '1') {
        return true;
      }

      return null;
    }
  },
  watch: {
    value: {
      handler(now, old) {
        this.current_field = now;
      }
    }
  }
};
</script>
